<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<%@ include file="/common/meta.jsp"%>
<%@ include file="/common/ec.jsp"%>
<%@include file="/common/validator.jsp"%>
<title>人员编辑</title>
</head>
<body>
<div class="x-panel">
  <div class="x-panel-header">人员管理</div>
  <div class="x-toolbar"></div>
  <s:form id="save" action="save.do" method="post" theme="simple">
  <s:hidden id="optionType" name="optionType"/>
  <div align="center">
  <fieldset style="width: 450px; padding: 50 10 5 10;">
	<legend>人员信息维护</legend>  
	<table width="450" border="0">
	  <tr>
	    <td align="right" width="100">
	    	人员编号:
	    </td>
	    <td width="350">
	    	<s:textfield id="xcrbh" name="model.xcrbh" cssStyle="width:200px;" cssClass="required"/>
	    </td>
	  </tr>
	  <tr>
	    <td align="right">
	    	姓　　名:
	    </td>
	    <td>
	    	<s:textfield id="xm" name="model.xm" cssStyle="width:200px;" cssClass="required"/>
	    </td>
	  </tr>
	   <tr>
	    <td align="right">
	    	密　　码:
	    </td>
	    <td>
	    	${model.mm }
	    	<s:password id="mm" name="model.mm" cssStyle="width:200px;" cssClass="pwdCheck"/>
	    	<span id="mmTips"></span>
	    </td>
	  </tr>
	   <tr>
	    <td align="right">
	    	确认密码:
	    </td>
	    <td>
	    	<s:password id="repmm" cssStyle="width:200px;" cssClass="passwordCheck"/>
	    	<span id="repMmTips"></span>
	    </td>
	  </tr>
	  <tr>
	    <td align="right">
	    	人员类别:
	    </td>
	    <td>
	    	<s:select id="rylb" name="model.rylb" list="rylbs" headerKey="-1" headerValue="-- 请选择类别 --" cssStyle="width:200px;" cssClass="rylbCheck"/>
	    	<span id="rylbTips"></span>
	    </td>
	  </tr>
	  <tr>
	    <td align="right">
	    	机　　构:
	    </td>
	    <td>
	    	<s:select id="jgm" name="model.jgm" list="jgdys" headerKey="-1" headerValue="-- 请选择机构 --" cssStyle="width:200px" cssClass="jgdyCheck"/>
	    	<span id="jgmTips"></span>
	    </td>
	  </tr>
	  <tr>
	    <td align="center" colspan="2">
	    	<s:submit value="保存" cssClass="button" />
	    	<s:reset value="重置" cssClass="button" />
	    </td>
	  </tr>
	</table>
  </fieldset>
  </div>
  </s:form>
</div>
<s:if test="model.xm != null">
	<script type="text/javascript">
	 	$('#mm').val("*********");
	    $('#repmm').val("*********");
	</script>
</s:if>

<script type="text/javascript">
	$(function(){
		$.validator.addMethod("passwordCheck", function(value, element) {
		    var res;
		    var pwd1 = $('#mm').val();
			var pwd2 = $('#repmm').val();
				if(pwd1 != null & pwd2 != null & pwd1 != '' & pwd2 != '') {
					if(pwd1 != pwd2) {
						res = "err";
						document.getElementById('repMmTips').innerHTML = '<font color="red">'+'两次密码不一致。'+'</font>';
					}else{
						res = "ok";
						document.getElementById('repMmTips').innerHTML = '&nbsp;请再次输入密码';
					}
				}
		    return res != "err";
		},"");
		//验证密码
		$.validator.addMethod("pwdCheck", function(value, element) {
		    var res;
			if(value.length < 6) {
				res = "err";
				document.getElementById('mmTips').innerHTML = '<font color="red">'+'密码小于6位。'+'</font>';
			}else{
				res = "ok";
				document.getElementById('mmTips').innerHTML = '&nbsp;密码应大于六位';
			}
		    return res != "err";
		},"");
	});
	
	$(function(){
		//人员类别检查
		$.validator.addMethod("rylbCheck", function(value, element) {
	        var res;
	  		if('-1' == value) {
  				res = "err";
  				document.getElementById('rylbTips').innerHTML = '<font color="red">'+'请选择人员类别'+'</font>';
	  		}else{
	  			document.getElementById('rylbTips').innerHTML = '<font color="red">&nbsp;</font>';
	  		}
	        return res != "err";
	    },"");
	});

	$(function(){
		 //验证密码一致性
		$.validator.addMethod("jgdyCheck", function(value, element) {
	        var res;
	  		if('-1' == value) {
 				res = "err";
 				document.getElementById('jgmTips').innerHTML = '<font color="red">'+'请选择所属机构'+'</font>';
	  		}else{
	  			document.getElementById('jgmTips').innerHTML = '<font color="red">&nbsp;</font>';
	  		}
	        return res != "err";
	    },"");
	});
	
	//增加验证
	$(document).ready(function() {
		$("#save").validate();
	});
</script>
</body>
</html>